<?php
require_once(dirname(dirname(__FILE__)) . '/app.php');

$shopList = Shop::GetAllShops();
//$serviceList = Service::GetAll();
//print_r($_POST['service_id']);
$shop = null;
if( $_GET['id'] != null ){
	$shop = Shop::GetById( abs( intval( $_GET['id'] ) ) );
}

if ( $_POST ) {
	if( $oauthMap[51] == null){
		exit;
	}
	$shop = array();
	$shop['shop_name'] = $_POST['shop_name'];
	$shop['first_shop'] = $_POST['first_shop'] == null ? 0 : $_POST['first_shop'];
	$shop['open_hour'] = $_POST['open_hour'];
	$shop['open_minute'] = $_POST['open_minute'];
	$shop['close_hour'] = $_POST['close_hour'];
	$shop['close_minute'] = $_POST['close_minute'];
	$shop['shop_img'] = $_POST['shop_img'];
	$shop['shop_introduce'] = $_POST['shop_introduce'];
	$shop['store_manager_img'] = $_POST['store_manager_img'];
	$shop['store_manager_introduce'] = $_POST['store_manager_introduce'];
	$shop['shop_access'] = $_POST['shop_access'];
	$shop['map_url'] = $_POST['map_url'];

	if( $_POST['shop_id'] < 1 ){
		Logs::setLog("==============----------------service||=create");
		$deviceId = Shop::Create($shop);
	}else{
		$shop['id'] = $_POST['shop_id'];
		Shop::Update($shop);
	}
	$first_shop =  $_POST['first_shop'];
	
	redirect( WEB_ROOT . "/service/shopManage.php?first_shop=$first_shop" );
}



include template('/service/shop_edit');
